/*
** alloc.c for 42sh in /home/guina_b/
** 
** Made by benoit guina
** Login   <guina_b@epitech.net>
** 
** Started on  Fri Jan 01 00:00:00 2010 benoit guina
** Last update Fri Jan 01 00:00:00 2010 benoit guina
*/

#include <stdlib.h>
#include <string.h>
#include "error.h"
#include "alloc.h"

void *xmalloc(int size, const char *file, unsigned int line)
{
  void *r;

  r = 0;
  if (size <= 0)
    error_print(SH_ERR_MALLOC_SIZE, size, file, line);
  else if (!(r = malloc(size)))
    error_print(SH_ERR_MALLOC, file, line);
  return (r);
}

void *xcalloc(int size, const char *file, unsigned int line)
{
  return (memset(xmalloc(size, file, line), 0, size));
}

void xfree(void *ptr)
{
  free(ptr);
}
